
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/base/base.jsp" %>
<%@ include file="/base/database.jsp" %>

<%
  
       request.setCharacterEncoding("utf-8");
  
      String leaveID =request.getParameter("leaveID");
      String courseID  =request.getParameter("courseID");
      String reason  =request.getParameter("reason");
      String daynum    =request.getParameter("daynum");
      String stuNo =request.getParameter("stuNo");
      String applytime  =request.getParameter("applytime");
      String status  =request.getParameter("status");
      String audittime =request.getParameter("audittime");
      String opinion =request.getParameter("opinion");

   StringBuffer sqlBuff=new StringBuffer();
   sqlBuff.append("insert into sys_leave(leaveID,courseID,reason,daynum,stuNo,applytime,status,audittime,opinion)");   
   sqlBuff.append("values(?,?,?,?,?,?,?,?,?)");
   String sql=sqlBuff.toString();

   String db_url="jdbc:mysql://localhost:3306/leave";
   String db_user="root";
   String db_pwd="";
   Class.forName("com.mysql.jdbc.Driver");

   Connection conn=DriverManager.getConnection(db_url, db_user, db_pwd);

    PreparedStatement pstmt=conn.prepareStatement(sql);
   
    int parameterIndex=1;
    
   	   pstmt.setNString(parameterIndex++, leaveID);
       pstmt.setNString(parameterIndex++, courseID);
       pstmt.setNString(parameterIndex++, reason);
       pstmt.setNString(parameterIndex++, daynum);
       pstmt.setNString(parameterIndex++, stuNo);
       pstmt.setString(parameterIndex++, applytime);
       pstmt.setString(parameterIndex++, status);
       pstmt.setString(parameterIndex++, audittime);
       pstmt.setNString(parameterIndex++, opinion);
       

       int c=pstmt.executeUpdate();
 
       if(pstmt!=null){
         pstmt.close();
        }
       if(conn!=null){
         conn.close();
         
       }
	process(request, response, "/page/instructor/leave/leave_list.jsp");

%>